import * as PIXI from 'pixi.js'
import { nameFont } from '@/utils/setting'
import { elementModule } from '@/utils/bundle'
export default async (data: Wx.Card.Data) => {
  const textContainer = new PIXI.Container()
  // 卡名底部
  const nameNegative = await elementModule(data, 1)
  nameNegative.anchor.set(0.5)
  textContainer.addChild(nameNegative)
  // 卡名文字
  const nameArr = data.name.split('')
  const nameSetting = nameFont(nameArr.length)
  nameArr.forEach((item, index) => {
    const text = new PIXI.Text({
      text: item,
      alpha: 0.8,
      style: {
        fontFamily: 'RZFont',
        fontSize: nameSetting.fontSize,
        fill: 0xffffff,
        align: 'center',
        dropShadow: {
          alpha: 0.55,
          distance: 3,
        },
      },
    })
    text.anchor.set(0.5)
    text.position.set(0, 30 - 256 / 2 + nameSetting.startY + index * nameSetting.lineSize)
    textContainer.addChild(text)
  })
  textContainer.scale.set(0.7)
  textContainer.position.set(22 - 292 / 2, (256 + 44 - 490) / 2 - 5)
  return textContainer
}
